<template>
  <div>
    <TopFilter :list="topFilterList" :cols="4" @filterChange="getRepairList" @onCollapse="collapseHandle"></TopFilter>
    <FilterTable
      ref="table"
      :isSelectColumn="false"
      :columns="columns"
      :params="fetchParams"
      :fetchapi="fetchApi"
      :datakey="'rows'"
      :onColumnsChange="columns => (this.selectColumn = columns)"
      :onRowSelectChange="columns => (this.selectColumn = columns)"
      height="400"
    ></FilterTable>
    <Drawer :visible.sync="examineVerify" title="查询区域" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <examineVerify :list="selectList" @closeFilter="closeFilter"></examineVerify>
    </Drawer>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import moment from 'moment';
import { getRepairList } from '@/api/repair/management/appeal';
import labourModel from '@/pages/repair/repairReception/repairBusinessManger/labourModel';
import examineVerify from './examineVerify';
export default {
  name: 'management',
  components: { labourModel, examineVerify },
  mixins: [dictionary],
  data() {
    this.BaseTable = null;
    return {
      topFilterList: this.createTopFilterList(),
      fetchParams: {},
      examineVerify: false,
      fetchApi: getRepairList,
      columns: this.createTableColumns(),
      selectList: {}
    };
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  methods: {
    createTopFilterList() {
      return [
        {
          type: 'INPUT',
          label: '问题序号',
          fieldName: 'PROBLEM_NO'
        },
        {
          type: 'INPUT',
          label: '统计月',
          fieldName: 'MONTH'
        },
        {
          type: 'RANGE_DATE',
          label: '导入日期',
          fieldName: 'dCheckBegin|dCheckEnd',
          placeholder: '选择日期',
          valeuFormat: 'yyyy-MM-dd'
        },
        {
          type: 'SELECT',
          label: '申诉状态',
          fieldName: 'STATUS',
          placeholder: '请选择...',
          itemList: []
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          fixed: 'left',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 70,
          fixed: 'left',
          render: props => {
            return (
              <div>
                <el-button size="small" type="text" icon="el-icon-success" onClick={() => this.submitForSettlement(props.row)}>
                  编辑
                </el-button>
              </div>
            );
          }
        },
        {
          title: '经销商代码',
          dataIndex: 'OWNER_CODE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商名称',
          dataIndex: 'OWNER_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '问题序号',
          dataIndex: 'PROBLEM_NO',
          sorter: true,
          filter: true,
          filterType: 'input',
          width: 125
        },
        {
          title: '统计月',
          dataIndex: 'MONTH',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车系名称',
          dataIndex: 'SERIES_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: 'VIN',
          dataIndex: 'VIN',
          sorter: true,
          filter: true,
          filterType: 'input',
          width: 125
        },
        {
          title: '进厂日期',
          dataIndex: 'ENTER_DATE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '送修人',
          dataIndex: 'DELIVERER',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '送修人电话',
          dataIndex: 'DELIVERER_MOBILE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: 'FIR问题描述',
          dataIndex: 'PROBLEM_DESC',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '厂家意见',
          dataIndex: 'TDS_OPINION',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '是否一次修复',
          dataIndex: 'IS_ONE_REPAIR',
          sorter: true,
          filter: true,
          filterType: 'input',
          filterItems: this.createDictList(1004)
        },
        {
          title: '申诉状态',
          dataIndex: 'STATUS',
          sorter: true,
          filter: true,
          filterType: 'input',
          filterItems: this.createDictList(1004)
        },
        {
          title: '车主姓名',
          dataIndex: 'CUSTOMER_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车牌号',
          dataIndex: 'LICENSE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '申诉人名称',
          dataIndex: 'APPEAL_MAN_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '申诉日期',
          dataIndex: 'APPEAL_DATE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '导入日期',
          dataIndex: 'OPERATE_DATE',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    // 搜索回调
    getRepairList(data) {
      console.log(data, 'data');
      // 根据搜索条件调用列表
      this.fetchParams = Object.assign({}, data);
    },
    // 点击展开收起重新计算table高度
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },

    submitForSettlement(val) {
      this.selectList = val;
      this.examineVerify = true;
    },
    closeFilter() {
      this.examineVerify = false;
      this.fetchParams = { ...this.fetchParams };
    }
  }
};
</script>

<style scoped></style>
